package cn.edu.nit.sys.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @Author xiaobai
 * @Date 2023/3/18 20:08
 * @Version 1.0.0
 */
@Getter
public enum UserEnum {

    DEFAULT("0", "未启用"),
    NORMAL("1", "正常"),
    LOCK("2", "冻结");

    @EnumValue
    private String code;
    @JsonValue
    private String label;

    UserEnum(String code, String label) {
        this.code = code;
        this.label = label;
    }

    public static String getCode(UserEnum name) {
        for(UserEnum userEnum : UserEnum.values()) {
            if(userEnum.equals(name)) {
                return userEnum.getCode();
            }
        }
        return "-1";
    }
}
